Go to Home Page
Questions?
Call 1-800-572-5517
 
  Go to Home Page  
  See all products
  See price schedules
  See manuals, tutorials, articles
  Download a free 30-day trial
  See user testimonials
  About Pacific Systems Group
 
 
SMF Tools
  See SMF Record Layouts
  See Sample SMF Reports
  Learn How to Export SMF Data
  Download Free SMF Reporting Software (30 days)
 
One of the greatest SMF record parsing programming languages I've ever seen. Chief, Large Systems Services Branch, NIH
  Choose Spectrum Writer to add 4GL to your product
  Report Writer Speedup Tips Article
Spectrum SMF Writer - the 4GL SMF Report Writer.

Add customized reports and PC export files to your product!

Table of Contents

NOTE: you can find this and other lessons in a
more complete and viewable format (including all Figures) in our Tutorial PDF.

Lesson 9. How to Specify the Sort Order and Control Breaks

  1. This lesson teaches you how to sort your report into the order you want. It also explains how to add control breaks to your report. And it shows how to use control breaks to create summary reports. The control statements discussed are:
  2. the SORT statement
  3. the BREAK statement
  4. the SUMMARY parm of the OPTIONS statement
How to Use the SORT Statement
  1. When no SORT statement is specified, Spectrum SMF Writer defaults to printing the report records in their original input file order. For SMF files, that is normally the order in which the records were logged by the SMF system. The sample SMF reports in the previous lessons all appeared in this default order.
  2. To print a report in a different order, just add a SORT statement. The SORT statement can appear anywhere after the INPUT statement. Only one SORT statement is allowed per report, but it may contain as many "sort fields" as you like. Spectrum SMF Writer will sort your report on all of the sort fields.
  3. For example, let's request a report from the SMF14 records and sort it on two fields:

SORT: SMF14_JOBID SMF14EXCP(D)

  1. Now the report will be sorted first on SMF14-JOBID . That is a computed field that was discussed on Here is an example of a character field that is handy for reports from many SMF record types, including type 14.. It has a unique value for each job in the SMF file. When the file has multiple SMF14 records for the same job, then those records will be sorted in descending SMF14EXCP order.
  2. The report in Figure _ uses the above statement.
  3. Using a SORT statement to specify the sort order of a report
    Using a SORT statement to specify the sort order of a report
  4. you can actually use the SMF14_JOBID in your own reports without even having to write a COMPUTE statement for it. This field is so useful that we have included the COMPUTE statement for it right in the copy library.
  5. The SORT statement can name any field in the input file (as well as any COMPUTE field). You are not limited to just the fields that are listed in the COLUMNS statement.
  6. You may also put a trailing #EQUAL parm after all of the sort fields. That parm causes "tie" records to remain in their original relative order.
  7. By default, Spectrum SMF Writer sorts reports into ascending order on each sort field. If you want to sort the report into descending order for a field, put the DESCENDING parm (or just DESC or D ) in parentheses immediately after the field name.
How to Use the BREAK Statement
  1. Consider the result of sorting the report in Figure _ on the SMF14-JOBID field. As you can see, it causes all of the records for a given job to be grouped together.
  2. Often it is desirable to perform special processing whenever one such group of records ends and another group is about to begin. For example, you might want to print a line of totals for the group (the job, in this case) that just ended. Or, you might want to print a few blank lines before the next group starts printing, or even skip to a new page. This processing is called control break processing.
  3. A control break occurs whenever one group of records ends and another group is about to begin. The field that is being grouped (for example, SMF14 - JOBID ) is called the control break field. A control break field must also be a sort field, since it is by being sorted that records are grouped together in the first place.
  4. You may designate any sort field as a control break field. Just name the field in a BREAK statement:

SORT: SMF14-JOBID SMF14EXCP(D)
BREAK: SMF14-JOBID

  1. The above statements make SMF14-JOBID a control break field (as well as a sort field). Now we will get job totals in the report whenever the lines for one job ends and another job is about to begin.
  2. After the totals, two blank lines will print. Then the report lines for the next job start to print, and so on.
  3. Figure _ shows a report that uses the above BREAK statement to produce a control break. Notice that at the breaks (by default) Spectrum SMF Writer prints: the value of the break field, the number of item in the control group, and totals for each numeric column. It also indicates the level of the break with a number of leading asterisks.
  4. Using the BREAK statement to create a control break
    Using the BREAK statement to create a control break
     
Control Break Spacing
  1. You can use additional parms in the BREAK statement to customize your control break. For example, you can specify a break spacing parm. This parm tells Spectrum SMF Writer what kind of spacing to perform at the control break. By default, Spectrum SMF Writer prints two blank lines at each control break (after the totals line). Use a spacing parm to request either a different number of blank lines, or to request a page break.
  2. For example, the following statement makes SMF14-JOBID a break field and specifies that 3 blank lines should print at the control break:

BREAK: SFM14-JOBID SPACE(3)

  1. If you want to skip to a new page whenever the contents of a field changes, use the PAGE spacing parm, like this:

BREAK: SMF14SID SPACE(PAGE)

  1. The SPACE(PAGE) parm specifies that, rather than printing 2 blank lines whenever the SMF14SID field (the System Identification) changes, the report should skip to a new page.
  2. you can also specify the NOTOTALS parm on the BREAK statement, if you only want blank lines or a new page at the break, and do not also want totals:

BREAK: SMF14SID NOTOTALS

How to Create a Summary Report
  1. A summary report is one which does not show the detail information for every record included in the report. Instead the detail information is summarized and only the totals are printed in the report.
  2. Control breaks are used to create the desired total lines. Consider again the report in Figure _. It is a detail report that lists the EXCP count for every DDNAME accessed by a job in the SMF file. The control break on SMF14-JOBID causes a total line to print after the detail lines for each job. By just adding the following statement, we can suppress the detail lines and print only those job totals:

OPTIONS: SUMMARY

  1. Figure _ shows a summary report that uses the above statement. This report just shows the total EXCP count for each job.
  2. Using the SUMMARY option to make a summary report
    Using the SUMMARY option to make a summary report
  3. if we intended to use this report as something more than a one-shot job, we would make some changes to improve its appearance. We could remove some or all of the character columns, since those fields are empty in the total lines.
  4. But for this example, we wanted to clearly demonstrate that any report that has a control break can easily be turned into a summary report -- just by adding one option to it.
Multiple Control Breaks
  1. You may designate more than one sort field as a control break field. Use a separate BREAK statement for each sort field that you want to break on.
  2. Consider these control statements:

COMPUTE: SMF14_TIMESTAMP = #FORMAT(SMF14RSD) + ' ' + #FORMAT(SMF14RST)
*
SORT: SMF14JBN SMF14_TIMESTAMP SMF14EXCP(D)
BREAK: SMF14JBN SPACE(3)
BREAK: SMF14_TIMESTAMP SPACE(1)

  1. In this example, we have, in effect, split the SMF14_JOBID field into two components: the jobname alone ( SMF14JBN ), and the reader start date/time in a separate field ( SMF14-TIMESTAMP ). By sorting on both of these fields (plus SMF30EXCP as the tie breaker), our report remains in the same order as in the previous example.
  2. A report with nested control breaks
    A report with nested control breaks
  3. But now we can break separately on two occasions. First we can break, as before, when each individual job ends and show its EXCP total. The break on SMF14_TIMESTAMP does that for us. That break's total line is followed by 1 blank line.
  4. And now we can have an additional break each time the jobname alone changes. The totals at that break will include all runs of a job with that name in the SMF file. The jobname break is followed by 3 blank lines.
  5. Notice that the number of asterisks in the default total lines serves as a visual indicator of the level of the break.
  6. All BREAK statements must appear after the SORT statement.
  7. When multiple BREAK statements are used, the BREAK statements may appear in any order. Note that the order of the BREAK statements does not determine which break is nested within the other. That is determined by the order of the fields in the SORT statement.
Summary
  1. Here is a summary of what we learned in this lesson:
  2. use the SORT statement to sort your report
  3. you can sort on multiple sort fields
  4. you can sort in either ascending or descending order
  5. use the BREAK statement to specify a control break field
  6. control break fields must also be sort fields
  7. use the SPACE parm to specify your own spacing at the control break
  8. you can specify multiple control breaks in the same report
  9. The next lesson will show you how to print statistics at control breaks, and how to write your own custom lines at the beginning and end of a control group.
To Learn More
  1. You can also learn how to:
  2. create a control break with the SORT statement
  3. specify control break spacing with the SORT statement
  4. request totals and statistics in the SORT statement
  5. use additional control break spacing parms, including one that skips to a new sheet of paper
  6. compute percentages and ratios that apply to an entire control group
  7. create multiple levels of summarization
  8. the complete syntax for the SORT and BREAK statements is given in and
NEXT LESSON: Customizing the Control Breaks

Spectrum SMF Writer - the 4GL SMF Report Writer.

Copyright 2024.
Pacific Systems Group.
All rights reserved.
Home | Products | Prices | Documentation | 30-Day Trials | Customer Reviews | Company | FAQ | Sample Reports | SMF Records
Send Your Comments or Questions